//
//  LGBasicInfoSugeryCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/9/14.
//

#import "LGBasicInfoBodayCell.h"

#define itemW  (Screen_W-viewPix(44))/4.0

@interface LGBasicInfoBodayCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *heightLabel;
/**   */
@property (nonatomic , strong)UILabel *weightLabel;
/**   */
@property (nonatomic , strong)UILabel *bmiLabel;
/**   */
@property (nonatomic , strong)UILabel *bmiStatusLabel;
/**   */
@property (nonatomic , strong)UILabel *waistLabel;
/**   */
@property (nonatomic , strong)UILabel *waistStatusLabel;
/**   */
@property (nonatomic , strong)NSDictionary *bmiDic;
/**   */
@property (nonatomic , strong)NSDictionary *waistDic;
/**   */
@property (nonatomic , strong)NSDictionary *bmiColorDic;
/**   */
@property (nonatomic , strong)NSDictionary *waistColorDic;
@end

@implementation LGBasicInfoBodayCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
//        NSDictionary *titleDic = @{@"0":@"正常",@"1":@"偏胖",@"2":@"肥胖",@"3":@"偏瘦"};
        self.bmiDic = @{@"1":@"肥胖",@"2":@"偏重",@"3":@"正常",@"4":@"偏瘦"};
        self.waistDic = @{@"1":@"偏高",@"2":@"正常",@"3":@"偏瘦"};
        self.bmiColorDic = @{@"3":@"#429BFF",@"2":@"#FF9704",@"1":@"#E53C39",@"4":@"#3DC997"};
        self.waistColorDic = @{@"1":@"#FE6603",@"2":@"#429BFF",@"3":@"#3DC997"};
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.heightLabel.text = LGNSString(dataDic[@"height"]);
    self.weightLabel.text = LGNSString(dataDic[@"weight"]);
    self.bmiLabel.text = (LGNSString(dataDic[@"bmi"]).length>0)?LGNSString(dataDic[@"bmi"]):@" ";
    self.waistLabel.text = LGNSString(dataDic[@"waistline"])?LGNSString(dataDic[@"waistline"]):@" ";
    NSString *bmiStauts = LGNSString(dataDic[@"bmi_status"]);
    NSString *waistStauts = LGNSString(dataDic[@"waistline_status"]);
    self.bmiStatusLabel.text = LGNSString(dataDic[@"bmi_status_content"]);
    self.waistStatusLabel.text = LGNSString(dataDic[@"waistline_status_content"]);
    self.bmiStatusLabel.textColor = [UIColor colorWithString:self.bmiColorDic[bmiStauts]];
    self.waistStatusLabel.textColor = [UIColor colorWithString:self.waistColorDic[waistStauts]];
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
  
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.top.equalTo(self.contentView).offset(-viewPix(15));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
        make.height.equalTo(@(viewPix(80)));
    }];
    UILabel *heightTitle = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    heightTitle.frame = CGRectMake(viewPix(12), viewPix(23), itemW, viewPix(20));
    heightTitle.attributedText = [@"身高(cm)" attributeString:@{NSFontAttributeName:LGFont(12),NSForegroundColorAttributeName:[UIColor colorWithString:@"#909399"]} range:NSMakeRange(2, 4)];
    [self.baseView addSubview:heightTitle];
    
    UILabel *weightTitle = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    weightTitle.frame = CGRectMake(kMaxX(heightTitle.frame), kMinY(heightTitle.frame), itemW, viewPix(20));
    weightTitle.attributedText = [@"体重(kg)" attributeString:@{NSFontAttributeName:LGFont(12),NSForegroundColorAttributeName:[UIColor colorWithString:@"#909399"]} range:NSMakeRange(2, 4)];
    [self.baseView addSubview:weightTitle];
    
    UILabel *bmiTitle = [UILabel lableWithText:@"BMI" colorString:@"#606266" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    bmiTitle.frame = CGRectMake(kMaxX(weightTitle.frame), kMinY(heightTitle.frame), itemW, viewPix(20));
    [self.baseView addSubview:bmiTitle];
    
    UILabel *waistTitle = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    waistTitle.frame = CGRectMake(kMaxX(bmiTitle.frame), kMinY(heightTitle.frame), itemW, viewPix(20));
    waistTitle.attributedText = [@"腰围(cm)" attributeString:@{NSFontAttributeName:LGFont(12),NSForegroundColorAttributeName:[UIColor colorWithString:@"#909399"]} range:NSMakeRange(2, 4)];
    [self.baseView addSubview:waistTitle];
    
    [self.baseView addSubview:self.heightLabel];
    [self.baseView addSubview:self.weightLabel];
    [self.baseView addSubview:self.bmiLabel];
    [self.baseView addSubview:self.bmiStatusLabel];
    [self.baseView addSubview:self.waistLabel];
    [self.baseView addSubview:self.waistStatusLabel];
    [self.heightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(heightTitle.mas_bottom).offset(viewPix(8));
        make.left.equalTo(heightTitle);
    }];
    
    [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.heightLabel);
        make.left.equalTo(weightTitle);
    }];
    
    [self.bmiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.heightLabel);
        make.left.equalTo(bmiTitle);
    }];
    
    [self.bmiStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bmiLabel.mas_right);
        make.bottom.equalTo(self.bmiLabel);
    }];
    
    [self.waistLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.heightLabel);
        make.left.equalTo(waistTitle);
    }];
    
    [self.waistStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.waistLabel.mas_right);
        make.bottom.equalTo(self.waistLabel);
    }];
    
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 10;
    }
    return _baseView;
}

-(UILabel *)heightLabel{
    if(!_heightLabel){
        _heightLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(18) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _heightLabel;
}

-(UILabel *)weightLabel{
    if(!_weightLabel){
        _weightLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(18) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _weightLabel;
}

-(UILabel *)bmiLabel{
    if(!_bmiLabel){
        _bmiLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(18) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _bmiLabel;
}

-(UILabel *)bmiStatusLabel{
    if(!_bmiStatusLabel){
        _bmiStatusLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _bmiStatusLabel;
}

-(UILabel *)waistLabel{
    if(!_waistLabel){
        _waistLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(18) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _waistLabel;
}

-(UILabel *)waistStatusLabel{
    if(!_waistStatusLabel){
        _waistStatusLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _waistStatusLabel;
}

//
//-(UILabel *)sugeryLabel{
//    if(!_sugeryLabel){
//        _sugeryLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
//    }
//    return _sugeryLabel;
//}
//
//-(UILabel *)zhijiaLabel{
//    if(!_zhijiaLabel){
//        _zhijiaLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
//    }
//    return _zhijiaLabel;
//}
//
//-(UIView *)lineView{
//    if(!_lineView){
//        _lineView = [[UIView alloc] init];
//        _lineView.backgroundColor = [UIColor colorWithString:@"#E1E1E1"];
//    }
//    return _lineView;
//}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
